﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Business;
using DevExpress.XtraEditors;

namespace CreateDb
{
    public partial class FormSchema : XtraForm
    {
        FormCreatDb Form { get; set; }

        public FormSchema(FormCreatDb form)
        {
            InitializeComponent();
            Form = form;
        }

        private void comboBoxEdit1_SelectedValueChanged(object sender, EventArgs e)
        {
            var obj = cboObjeto.EditValue.ToString();
            if (obj.Equals(""))
            {
                return;
            }
            try
            {
                var td = ((Npgsql.NpgsqlConnection)Form.GetFactory().OpenSession().Connection).
                GetSchema(obj);
                gridControl1.DataSource = td.DefaultView;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao carregar o esquema selecionado.\n"+ex.Message);
            }
            
        }
    }
}
